import axios from '../utils/http'

// 获取菜单列表
export async function getMenuList() {
  const res = await axios.get('/api/menulist?istree=1')
  if (res.code === 200) {
    return res.list
  }
  return false
}
// 根据id获取菜单信息
export async function getMenuById(id) {
  // const res = await axios.get('/api/menuinfo?id='+id);
  const res = await axios.get('/api/menuinfo', { params: { id }})
  if (res.code === 200) {
    return res.list
  }
  return false
}

export async function handelBook(type, params, method = 'get') {
  const res = await axios[method](`/api/cloud_data/ttshitu/${type}`, params)
  console.log('params', params)
  if (res.success) {
    return res.data
  }
  return false
}

export async function handelIceExtend(type, params, method = 'get') {
  const res = await axios[method](`/api/cloud_data/bingTop/${type}`, params)
  if (res.success) {
    return res.data
  }
  return false
}

export async function handelFeedNumber(type, params, method = 'get') {
  const res = await axios[method](`/api/cloud_data/raise/${type}`, params)
  if (res.success) {
    return res.data || true
  }
  return false
}
// 种树
export async function handelRegister(containerIp, count) {
  const res = await axios.get(
    `/api/cloud_curbs/batch_register?containerIp=${containerIp}&number=${count}`
  )
  if (res.success) {
    return res
  }
  return false
}
// 群控管理
export async function Register(deviceId, count) {
  const res = await axios.get(
    `/api/cloud_curbs/batch_register?containerIp=${deviceId}&number=${count}`
  )
  if (res.success) {
    return res
  }
  return false
}

export async function handelFeed(id) {
  const res = await axios.get(`/api/cloud_curbs/batch_raise?containerIp=${id}`)
  if (res.code === 200) {
    return res
  }
  return false
}
